<template>
  <div class="wrap">
    <div class="search">
      <g-search></g-search>
    </div>
    <div class="con">
      <div class="left">
        <ul>
          <li
            v-for="(item,index) in leftArr"
            :key="item.id"
            @click="n=index"
            :class="index==n?'select':''"
          >{{item.catename}}</li>
        </ul>
      </div>
      <div class="right">
        <div class="phone" v-for="item in leftArr" :key="item.id">
          <h3>{{item.catename}}</h3>
          <p v-if="!item.children">暂无数据</p>
          <div class="small">
            <div>
              <!-- <img src alt @click="$router.push('/list')" /> -->
              <img
                v-for="i in item.children"
                :key="i.id"
                :src="$pre+i.img"
                alt
                @click="$router.push('/list?id='+i.id+'&type=2')"
              />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { reqAllCates } from "../../http/api";
export default {
  data() {
    return {
      leftArr: [],
      n: 0,
    };
  },
  mounted() {
    reqAllCates().then((res) => {
      console.log(res);
      if (res.data.code == 200) {
        this.leftArr = res.data.list;
      }
    });
  },
};
</script>

<style scoped>
.select {
  color: white;
}
img {
  height: 1.5rem;
  width: 1.5rem;
  background: brown;
  border-radius: 50%;
  border: none;
}
.con .phone > div {
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
}
.con .phone {
  padding: 0.1rem;
  box-sizing: border-box;
}
.con .left li {
  height: 1.4rem;
  line-height: 1.4rem;
  text-align: center;
}
.wrap {
  font-size: 0.4rem;
}
.search {
  width: 100%;
  height: 1rem;
  background: tomato;
  padding-bottom: 0.2rem;
}
.con {
  display: flex;
}
.con .left {
  flex: 2;
  background: tomato;
  /* height: 10rem; */
}
.con .right {
  flex: 5;
  /* background: skyblue; */
  /* height: 10rem; */
  border: 0.25rem solid #ccc;
  box-sizing: border-box;
}
</style>